﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using YArchitech.Controls;

namespace YArchitech.LIB
{
	public class ControlJudgement
	{
		public static bool IsControlEmpty(Control tb)
		{
			bool result = false;
			if (tb.Text.Trim() == "")
			{
				result = true;
				tb.Focus();
			}
			return result;
		}

		public static bool IsAllControlEmpty(List<Control> list)
		{
			bool result = false;
			if (list.Count > 0)
			{
				using (List<Control>.Enumerator enumerator = list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						if (ControlJudgement.IsControlEmpty(enumerator.Current))
						{
							result = true;
							YJKMessageBox.Information("所有参数均不能为空");
							break;
						}
					}
				}
			}
			return result;
		}

		public static bool IsControlNumber(Control tb)
		{
			bool flag = true;
			bool result;
			try
			{
				if (Convert.ToDouble(tb.Text.Trim()) <= 0.0)
				{
					flag = false;
					tb.Focus();
				}
				result = flag;
			}
			catch (Exception)
			{
				flag = false;
				result = flag;
			}
			return result;
		}

		public static bool IsAllControlNumber(List<Control> list)
		{
			bool result = false;
			if (list.Count > 0)
			{
				using (List<Control>.Enumerator enumerator = list.GetEnumerator())
				{
					while (enumerator.MoveNext())
					{
						if (!ControlJudgement.IsControlNumber(enumerator.Current))
						{
							result = false;
							break;
						}
						result = true;
					}
				}
			}
			return result;
		}
	}
}
